function [ arrImage, arrayImageResultColor, arrayResultPosition, isSuccess ] = DisplayImage( arrImaBinary, arrImaOrg, arrayResultPositionInput, IS_DEBUG, ...
    conFilter2,name, FOLDER_RESULT )
%UNTITLED3 Summary of this function goes here
%   Detailed explanation goes here


arrImage = {};
arrayImageResultColor = {};
arrayResultPosition = {};
count = 1;

for i=1:length(arrImaOrg)
    
    h1 = ~arrImaBinary{i};
    
    %% suy nghi o cho nay
    % neu h1 chay sai va dao h1 chay dung tuc la bien so mau khac chay van
    % dung hoac co the check mau de kiem tra mau cua bien so
    
    %% Phan tich thanh phan lien thong de lay ra duoc so luong cac obnject trong hinh h1
    % sau do tien hnah phan tich cac object de lay ra nhung object
    % co chieu cao thoa
    % neu kich thuoc h1 ty le thuoc hinh chu nhat thi ty le chieu cao cua
    % object phai >50% cua chieu cao h1
    % neu kich thuoc h1 ty le thuoc hinh vuong thi ty le chieu cao object
    % phai >30% cua chieu cao h1
    % dong thoi dien tich phai >10% kich thuoc bien so
    % nhung object duoc chon se lay ra min max chieu cao va luu vao mang de
    % tien hanh tinh so luong doi tuong duoc cross ngang qua.

    ccw =  bwconncomp(h1, 4);
    featureData = regionprops(ccw,'BoundingBox');
    
%     % show image test
%     labeled = labelmatrix(ccw);
%     color_binary = label2rgb(labeled, @spring, 'c', 'shuffle');
%     if (IS_DEBUG)
%         imwrite(color_binary,strcat(FOLDER_RESULT,'\',name,'\','_2DISPLAY_color',strcat(num2str(i)),'.JPG'),'JPG');
%     end
    
    %show anh h1 truoc khi xu ly
    if (IS_DEBUG)
        imwrite(h1,strcat(FOLDER_RESULT,'\',name,'\','_2DISPLAY_before process',strcat(num2str(i)),'.JPG'),'JPG');
    end
    
    [ho,wo] = size(h1);
    
    
    %setup thong so
    % kiem tra xem hinh dang cua object de quyet dinh thong so
    if (wo/ho>2)
        % hinh chu nhat
        RATE_CHOOSE_HEIGHT = 0.5;    
        RATE_CHOOSE_AREA = 0.1;
        NUM_MIN_CHANGE = 15;
        NUM_MAX_CHANGE = 30;
    else
        RATE_CHOOSE_HEIGHT = 0.3;    
        RATE_CHOOSE_AREA = 0.04;
        NUM_MIN_CHANGE = 6;
        NUM_MAX_CHANGE = 20;
    end
    
    % calculate sub postion of line cross
    Ys = 1;
    [Ye, Xe] = size(h1);
    array = DevideSublineBinary(Ys, Ye);
    crossObject = 0;
    %show anh h1 de debug
    figure(1);
    imshow(h1);
    % for loop get all object
    %calculate all pixel of all objects
    ao = 0;
    for k1=1:ccw.NumObjects 
        ao = ao + length(ccw.PixelIdxList{k1});
    end
    
    for k=1:ccw.NumObjects        
        curh = featureData(k).BoundingBox(4);
        oh1 = featureData(k).BoundingBox(2);
        oh2 = featureData(k).BoundingBox(2) + featureData(k).BoundingBox(4);
        sizeObject = length(ccw.PixelIdxList{k});
        ratioObjectAreaTemp = length(ccw.PixelIdxList{k})/ao;
        % debug show object
        grain = false(size(h1));
        grain(ccw.PixelIdxList{k}) = true;
        figure(2);
        imshow(grain);
            
        % neu obvject khong duoc chon tuc object la nhieu thi loai bo khoi
        % hinh h1
        if (curh/ho < RATE_CHOOSE_HEIGHT || ratioObjectAreaTemp < RATE_CHOOSE_AREA )    
            h1(ccw.PixelIdxList{k}) = false;
        else
            % Show object hien tai thao dieu kien
            figure(3);
            imshow(grain);
            
            % tinh toan xac dinh line co cross qua object hay ko bang cach
            % tinh toa do y1 va y2 cua object, sau do lay hOject tru cho h1
            % va h2 sau do nhan lai neu tich <0 thi nam giua tuc cross va
            % nguoc lai
            valueInsert = (array - oh1).*(array -oh2);
            if (sum(valueInsert<0)>0)
                crossObject = crossObject +1;
            end
        end
        clear curh  curw;
    end
    
    %show anh h1 sau khi xu ly
    if (IS_DEBUG)
        imwrite(h1,strcat(FOLDER_RESULT,'\',name,'\','_2DISPLAY_after process',strcat(num2str(i)),'.JPG'),'JPG');
    end
    
    %% aaaa   
    
    
    % 2. calculate num 0 and num 1
    L = {};
    countAvailLine = 0;

    
    save = '';
    for runI=1:3
        L{runI} = h1(array(runI),:);
        [countre, ratio] = ProcessEachRow(h1(array(runI),:));
        save = strcat(save,'-',num2str(countre));
        if ( countre >= NUM_MIN_CHANGE && countre <= NUM_MAX_CHANGE)
            %             if (countre<10)
            %                 if sum(crossObject{runI}<0)>=3
            %                     countAvailLine = countAvailLine + 1;
            %                 end
            %             else
            %                 if sum(crossObject{runI}<0)>=4
            %                     countAvailLine = countAvailLine + 1;
            %                 end
            %             end
            countAvailLine = countAvailLine + 1;
        end
    end
    
    if (IS_DEBUG)
        imwrite(h1,strcat(FOLDER_RESULT,'\',name,'\','_2DISPLAY_',strcat(num2str(i),'-line-',num2str(countAvailLine),'-detail-',save,'-co-',num2str(crossObject)),'.JPG'),'JPG');
    end
    % check dieu kie
    if (countAvailLine > 1 && crossObject > 5)
        arrImage{count} = arrImaBinary{i};
        arrayImageResultColor{count} = arrImaOrg{i};
        arrayResultPosition{count} = arrayResultPositionInput{i};
        %% write to file
        %DEBUG
        %              IS_DEBUG = true;
        if (IS_DEBUG)
            imwrite(h1,strcat(FOLDER_RESULT,'\',name,'\','_3RESULT_',name,strcat(num2str(i),'-line-',num2str(countAvailLine)),'.JPG'),'JPG');
            imwrite(arrImaOrg{i},strcat(FOLDER_RESULT,'\',name,'\','_3RESULTCOLOR_',name,strcat(num2str(i),'-line-',num2str(countAvailLine)),'.JPG'),'JPG');
        end
        count = count + 1;
    else
    end
    clear h1 h2;
end
isSuccess = 1;
clear count;
end

